package com.kuizii.discovery.client;

import com.kuizii.common.LiteServiceRegistration;
import com.kuizii.discovery.net.IOManager;
import com.kuizii.discovery.net.NettyIOManager;
import com.netflix.loadbalancer.ServerList;

import java.util.List;


public class DefaultDiscoveryServer implements DiscoveryServer {

    private DiscoveryProperties discoveryProperties;
    IOManager ioManager;

    public DefaultDiscoveryServer(DiscoveryProperties discoveryProperties) {
        new DefaultDiscoveryServer(discoveryProperties, new NettyIOManager());
    }

    public DefaultDiscoveryServer(DiscoveryProperties discoveryProperties, IOManager ioManager) {
        this.discoveryProperties = discoveryProperties;
        this.ioManager = ioManager;
        initServer();
    }

    public void initServer() {

        LiteServiceRegistration registration = new LiteServiceRegistration(discoveryProperties.getBindIp(), discoveryProperties.getPort());
        registration.setServiceId(discoveryProperties.getServiceName());
        registration.setClusterId(discoveryProperties.getClusterId());
        registration.setSecurityKey(discoveryProperties.getSecurityKey());
        registration.setSecurityValue(discoveryProperties.getSecurityValue()
        );
    }

    @Override
    public ServerList getServerList() {
//        List serverList = ioManager.getServerList();
        return null;
    }
}
